﻿using System;
using System.Linq;
using System.Collections.Generic; 
using NTTDATA.BEENChina.ResultCertification.Config; 

namespace NTTDATA.BEENChina.ResultCertification.Checker.Text
{
    [Serializable]
    [VerfityAttribute(Id = "VerfityTX0412", Name = "番号检证:多个番号不是用．连接的抽出)", CategoryType = EnumCategoryType.文字列, Model = true)]
    public class VerfityTx0412 : VerfityOneResult
    {
        

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;

            if (entryCommon == "30"  ||
                 entryCommon == "20")
            {
                return false;
            }

            foreach (var rowResult in result)
            {
                foreach (var colResult in rowResult)
                {

                    bresult = CheckErrorResult(colResult);

                    if (bresult)
                        break;
                }

                if (bresult)
                    break;
            }


            if (bresult)
            {
                System.Console.WriteLine("VerfityTX0412"); 
            }
            return bresult;
        }

        /// <summary>
        /// 番号是两位以上数字且不是１０的时候抽出
        /// </summary>
        /// <param name="colResult"></param>
        /// <returns></returns>
        private bool CheckErrorResult(string colResult)
        {
  
            var splitEntryResult = new Split.SplitEntryResult(ChildImageObject.CategorySetting.DataFormat, colResult);

            string numberCell = splitEntryResult.GetNumberCell();

            var codes = numberCell.Split(new string[] {"/", "．","." }, StringSplitOptions.None);

            return codes.Any(t =>
                                 {
                                    

                                     if (Util.StrHelper.IsNumeric(t))
                                     {
                                         int current ;
                                         int.TryParse(t, out current );

                                         if (current > 10)
                                             return true;

                                     }

                                     return false;
                                    
                                     
                                 }); 
            
        }


    }
}